home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_pow_thermal_m.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
6KB
|
209 lines
# Jedi Knight MOTHS Cog Script
#
# POW_THERMAL_m.COG
#
# POWERUP Script - Thermal Detonators
#
# [YB, CYW, SRS]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
template explode=+medium_exp local
template projectile=+grenade2 local
thing powerup local
thing player local
thing sender local
int bin=4 local
sound pickupsnd=thrmlpu2.wav local
sound respawnsnd=Activate01.wav local
flex amount local
#for the projectiles
vector dir local
int bin_contents=0 local
int autopickup=0 local
int damage local
message created
message damaged
message touched
message taken
message respawn
message timer
end
# ========================================================================================
code
created:
SetThingUserData(GetSenderRef(), 30); // set the initial user data (i.e. "health")
Return;
# ............................................................................................
touched:
if (GetWeaponBin(bin) == -1)
return;
player = GetSourceRef();
if (GetThingType(player) == 10) // Can only be taken by players.
{
amount = GetInv(player, GetWeaponBin(bin));
if (IsMulti() || (amount < GetInvMax(player, GetWeaponBin(bin))))
{
TakeItem(GetSenderRef(), -1);
call taken;
}
}
Return;
# ........................................................................................
damaged:
damage = GetParam (0);
sender = GetSenderRef();
// only take damage 33% of the time
if(rand() < 0.33)
return;
// If it's already dead, don't allow any more damage.
if (!GetThingUserData (sender))
return;
// see if this will cause the explosion
if (GetThingUserData (sender) <= damage)
{
SetThingUserData (sender, 0);
// timer for base explosion
SetTimerEx ((Rand () * 0.5), sender, 1, 0);
}
else
{
SetThingUserData (sender, GetThingUserData (sender) - damage);
}
ReturnEx (0);
return;
# ........................................................................................
taken:
if (GetWeaponBin(bin) == -1)
return;
player = GetSourceRef();
powerup = GetSenderRef();
// // If the object has been destroyed, don't award it to the player.
// if (!GetThingUserData (powerup))
// return;
// Print("Thermal Detonators");
jkPrintUNIString(player, GetWeaponBin(bin));
// Do effects.
PlaySoundLocal(pickupsnd, 1, 0, 0);
AddDynamicTint(player, 0.0, 0.0, 0.2);
// store the old bin contents
bin_contents = GetInv(player, GetWeaponBin(bin));
// Increment powerup amount.
ChangeInv(player, GetWeaponBin(bin), 3.0);
// Check for Auto Pickup
autopickup = GetAutoPickup();
if((autopickup & 1) && !(autopickup & 2)) // DANGEROUS
{
if(!bin_contents)
{
if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
{
if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
{
SelectWeapon(player, GetWeaponBin(bin));
Return;
}
}
}
}
// Check for Auto Reload
if(GetAutoReload() & 1)
{
if(!bin_contents)
{
if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
{
// Try to autoselect and see if the best weapon is the TD
if(AutoSelectWeapon(player, 2) == bin) SelectWeapon(player, GetWeaponBin(bin));
}
}
}
return;
# ........................................................................................
respawn:
SetThingUserData(GetSenderRef(), 30); // set the initial user data (i.e. "health")
PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
return;
# ........................................................................................
timer:
sender = GetSenderId ();
damage = GetParam (0);
if (damage == 1)
{
// cause the base explosion
powerup = CreateThing (explode, sender);
SetTimerEx (0.25, sender, 2, 0);
}
else
if (damage == 2)
{
if ((Rand () * 100) <= 75)
{
// and sling projectile 1
powerup = CreateThingNR(projectile, sender);
// x & y generate a number from -1 -> 1, z is 0 -> 1
dir = VectorSet (((Rand () * 2) - 1), ((Rand () * 2) - 1), Rand ());
SetThingVel (powerup, VectorScale (dir, (Rand () * 5) + 3));
}
if ((Rand () * 100) <= 75)
{
// and sling projectile 2
powerup = CreateThingNR(projectile, sender);
// x & y generate a number from -1 -> 1, z is 0 -> 1
dir = VectorSet (((Rand () * 2) - 1), ((Rand () * 2) - 1), Rand ());
SetThingVel(powerup, VectorScale (dir, (Rand () * 5) + 3));
}
TakeItem (sender, -1);
}
return;
end